﻿@model Model.Object.HoaDon
@{
    ViewBag.Title = "Thanhtoan";
    Layout = "~/Views/Shared/_LayoutWebmini.cshtml";
    var sl = (List<int>)ViewBag.soluong;
    var lstdn = (List<Model.Object.SanPham>)ViewBag.dssanphamdn;
    int tongthanhtoan = 0;
}
@if(sl.Count<=0)
{
    @Html.Action("Giotrong", "ViewHelper")
}
else{
<div class="col-main">
    @using (Html.BeginForm())
    {
        <fieldset class="group-select" style="margin: 0;">


            <script>

                Element.prototype.triggerEvent = function (eventName) {
                    if (document.createEvent) {
                        var evt = document.createEvent('HTMLEvents');
                        evt.initEvent(eventName, true, true);

                        return this.dispatchEvent(evt);
                    }

                    if (this.fireEvent)
                        return this.fireEvent('on' + eventName);
                }

</script>
            <p class="onestepcheckout-login-link">
                <span>Nếu bạn có tài khoản, hãy </span>
                <a id="ajax_login_link" href="https://www.nongsanngon.com.vn/customer/account/login/"><strong><u>đăng nhập</u></strong></a>
                <span>để tiết kiệm thời gian</span>
            </p>
            <p id="onestepcheckout-error-inform" style="display: none;">Có lỗi xảy ra trong thông tin mà bạn khai báo, hãy kiểm tra nhưng thông tin chưa khai báo đúng và điền lại</p>



            <div class="onestepcheckout-threecolumns checkoutcontainer onestepcheckout-skin-generic onestepcheckout-enterprise">
                <div class="onestepcheckout-column-left">
                    <div id="billing_address">
                        <script type="text/javascript">
                            var billing = new Billing();
            </script>
                        <ul>
                            <li>
                                <p class="onestepcheckout-numbers onestepcheckout-numbers-1">Thông tin liên hệ</p>
                            </li>
                            <li>
                                <div>
                                    <ul id="billing_address_list">











                                        <li class="clearfix">
                                            <div class="input-box input-firstname">
                                                @Html.LabelFor(m => m.Ho_ten_nhan)<span class="required">*</span>
                                                @Html.TextBoxFor(m => m.Ho_ten_nhan, new { @class = "required-entry input-text" })
                                                <h6 style="color:red" >@Html.ValidationMessageFor(m => m.Ho_ten_nhan)</h6>
                                            </div>

                                        </li>
                                        <li class="clearfix">
                                            <div class="input-box input-email">
                                                @Html.LabelFor(m => m.Email_nhan)<span class="required">*</span>
                                                @Html.TextBoxFor(m => m.Email_nhan, new { @class = "validate-email required-entry input-text" })
                                               <h6 style="color:red" > @Html.ValidationMessageFor(m => m.Email_nhan)</h6>


                                            </div>
                                           @* <div class="clearfix" id="onestepcheckout-email-error" style="display: none">
                                                <div id="onestepcheckout-email-error-message" class="onestepcheckout-error">Địa chỉ email không hợp lệ</div>
                                            </div>*@
                                            <div class="input-box input-telephone">
                                                 @Html.LabelFor(m => m.SDT_nhan)<span class="required">*</span>
                                                @Html.TextBoxFor(m => m.SDT_nhan, new { @class = "required-entry input-text" })
                                               <h6 style="color:red" > @Html.ValidationMessageFor(m => m.SDT_nhan)</h6>
                                                
                                            </div>
                                        </li>
                                        <li class="clearfix">
                                            <div class="input-box input-address">
                                                 @Html.LabelFor(m => m.Dia_chi_nhan)<span class="required">*</span>
                                                @Html.TextBoxFor(m => m.Dia_chi_nhan, new { @class = "required-entry input-text onestepcheckout-address-line" })
                                               <h6 style="color:red" >@Html.ValidationMessageFor(m => m.Dia_chi_nhan)</h6>
                                            </div>
                                        </li>
                                        <li class="clearfix">
                                            <div style="display: none;" class="input-box input-country">
                                                <label for="billing:country_id">Quốc gia <span class="required">*</span></label><br />
                                                <select name="billing[country_id]" id="billing:country_id" class="validate-select" title="Quốc gia">
                                                    <option value=""></option>
                                                    <option value="VN" selected="selected">Việt Nam</option>
                                                </select>
                                            </div>
                                        </li>
                                        <li class="clearfix">
                                            <img height="" src="" />
                                           @* <div class="input-box create_account">
                                                <input id="id_create_account" type="checkbox" name="create_account" value="1" />
                                                <label for="id_create_account">Tạo tài khoản cho lần sử dụng sau</label>
                                            </div>*@

                                            <script>
                                                //<![CDATA[
                                                function getRandomInt(min, max) {
                                                    return Math.floor(Math.random() * (max - min + 1)) + min;
                                                }
                                                function generatePassword(numchar, prefix) {
                                                    var partern = "abcdefghijklmnopqrstuvxyxwABCDEFGHIJKLMNOPQRSTUVXYZW1234567890";
                                                    var parternArray = new Array();
                                                    parternArray = partern.split("");
                                                    var resultPasswordArray = new Array();
                                                    for (var i = 0; i < numchar; i++) {
                                                        var randomNumer = getRandomInt(0, parseInt(parternArray.length));
                                                        resultPasswordArray[i] = parternArray[randomNumer];
                                                    }
                                                    var resultPassword = prefix + "";
                                                    for (var j = 0; j < resultPasswordArray.length; j++) {
                                                        resultPassword += resultPasswordArray[j];
                                                    }
                                                    return resultPassword;
                                                }
                                                function fireEvent(element, event) {
                                                    if (document.createEventObject) {
                                                        // dispatch for IE
                                                        var evt = document.createEventObject();
                                                        return element.fireEvent('on' + event, evt)
                                                    }
                                                    else {
                                                        // dispatch for firefox + others
                                                        var evt = document.createEvent("HTMLEvents");
                                                        evt.initEvent(event, true, true); // event type,bubbling,cancelable
                                                        return !element.dispatchEvent(evt);
                                                    }
                                                }

                                                document.observe("dom:loaded", function () {
                                                    $("onestepcheckout-li-password").hide();

                                                    $("id_create_account").observe("click", function (e) {
                                                        var element = e.element();
                                                        if (element.checked) {
                                                            $("input-password-options-wrapper").show();
                                                            $("input-password-options").show();
                                                            var pwd = generatePassword(7, "");
                                                            $("billing:customer_password").value = pwd;
                                                            $("billing:confirm_password").value = pwd;
                                                        }
                                                        else {
                                                            $("input-password-options-wrapper").hide();
                                                        }
                                                    });
                                                    $("pwd-selector1").observe("click", function (e) {
                                                        var element = e.element();
                                                        var pwd = generatePassword(7, "");
                                                        $("onestepcheckout-li-password").hide();
                                                        $("billing:customer_password").value = pwd;
                                                        $("billing:confirm_password").value = pwd;
                                                    });
                                                    $("pwd-selector2").observe("click", function (e) {
                                                        var element = e.element();
                                                        $("onestepcheckout-li-password").show();
                                                        $("billing:customer_password").value = "";
                                                        $("billing:confirm_password").value = "";
                                                    });
                                                });
                                                //]]>
        </script>
                                        </li>

                                       @* <div id="input-password-options-wrapper">
                                            <div id="input-password-options" style="display: none;">
                                                <input id="pwd-selector1" type="radio" name="pwd-option-selector" checked value="1" />
                                                Tạo mật khẩu tự động<br />
                                                <label class="pwd-description">mật khẩu đặng nhập sẽ đuợc tạo tự động bởi hệ thống & gửi vào email của bạn</label><br />
                                                <input id="pwd-selector2" type="radio" name="pwd-option-selector" value="2" />
                                                Tự tạo mật khẩu
           
                                            </div>

                                            <li id="onestepcheckout-li-password" style="display: none;">
                                                <div class="input-box input-password">
                                                    <input type="password" placeholder="Mật khẩu" class="required-entry validate-password input-text customer-password" value="" title="Password" id="billing:customer_password" name="billing[customer_password]" />
                                                </div>
                                                <div class="input-box input-password">
                                                    <input type="password" placeholder="Xác nhận mật khẩu" class="required-entry validate-password input-text confirm-password" value="" id="billing:confirm_password" title="Confirm Password" name="billing[confirm_password]" />
                                                </div>
                                            </li>
                                        </div>*@
                                       @* <li class="no-display">
                                            <input type="hidden" name="billing[save_in_address_book]" value="1" /></li>*@
                                    </ul>
                                </div>
                            </li>
                            <li style="display: none;">
                                <input type="hidden" name="billing[use_for_shipping]" id="billing:use_for_shipping_yes" value="1" />
                            </li>
                            <li>
                                <script>
                                    //<![CDATA[
                                    jQuery(document).ready(function () {
                                        jQuery('#use_for_shipping_yes_visible').removeAttr('checked');
                                        _initCheckedUseShippingYes();
                                        jQuery('#use_for_shipping_yes_visible').click(function () {
                                            _initCheckedUseShippingYes();
                                        });
                                    });
                                    var _initCheckedUseShippingYes = function () {
                                        var thisChecked = jQuery('#use_for_shipping_yes_visible').attr('checked');
                                        //var targetChecked = jQuery('input[name="billing[use_for_shipping]"]').attr('checked');
                                        if (thisChecked) {
                                            jQuery('input[name="billing[use_for_shipping]"]').val(0);
                                            jQuery('#shipping_address_list').show();
                                            jQuery('#shipping_address').show();
                                        } else {
                                            jQuery('input[name="billing[use_for_shipping]"]').val(1);
                                            jQuery('#shipping_address').hide();
                                        }
                                        return;
                                    }
                                    //]]>
                    </script>
                               @* <div class="input-box input-different-shipping">
                                    <input type="checkbox" id="use_for_shipping_yes_visible" value="1" />
                                    <label for="use_for_shipping_yes_visible">Giao hàng tới địa chỉ khác</label>
                                </div>*@
                            </li>
                        </ul>
                    </div>
                   @*<div id="shipping_address" style="display: none">
                        <script type="text/javascript">
                            var shipping = new Shipping();
            </script>
                        <ul>
                            <li class="shipping-address-title">Địa chỉ giao hàng                </li>
                            <li id="shipping_address_list" style="display: none;">
                                <div id="">
                                    <ul>





                                        <li class="clearfix">
                                            <div class="input-box input-firstname">
                                                <label for="shipping:firstname">Họ Tên<span class="required">*</span></label><br />
                                                <input class="required-entry input-text" type="text" name="shipping[firstname]" id="shipping:firstname" value="" />
                                            </div>
                                            <div style="display: none;" class="input-box input-lastname">
                                                <label for="shipping:lastname">Họ Tên <span class="required">*</span></label><br />
                                                <input class="input-text" type="text" name="shipping[lastname]" id="shipping:lastname" value="" />
                                            </div>
                                        </li>
                                        <li class="clearfix">
                                            <div class="input-box input-telephone">
                                                <label for="shipping:telephone">Điện thoại <span class="required">*</span></label><br />
                                                <input type="text" name="shipping[telephone]" value="" title="Điện thoại" class="required-entry input-text" id="shipping:telephone" />
                                            </div>
                                        </li>
                                        <li class="clearfix">
                                            <div class="input-box input-address">
                                                <label for="shipping:street1">Địa chỉ liên hệ<span class="required">*</span></label><br />
                                                <input type="text" title="Street Address 1" name="shipping[street][]" id="shipping:street1" value="" class="required-entry input-text onestepcheckout-address-line" />
                                            </div>
                                        </li>
                                        <li class="clearfix">
                                            <div class="input-box input-country" style="display: none;">
                                                <label for="shipping:country_id">Quốc gia <span class="required">*</span></label><br />
                                                <select name="shipping[country_id]" id="shipping:country_id" class="validate-select" title="Quốc gia" onchange="shipping.setSameAsBilling(false);">
                                                    <option value=""></option>
                                                    <option value="VN" selected="selected">Việt Nam</option>
                                                </select>
                                            </div>
                                        </li>

                                        <li class="no-display">
                                            <input type="hidden" name="shipping[save_in_address_book]" value="1" /></li>
                                    </ul>
                                    <input type="hidden" name="shipping[address_id]" value="32047" id="shipping:address_id" />
                                    <!-- END LIST OF SHIPPIING FIELDS -->
                                </div>
                            </li>
                        </ul>
                    </div>*@

                </div>

                <div class="onestepcheckout-column-middle">




                    <p class="onestepcheckout-numbers onestepcheckout-numbers-2">Phương thức thanh toán</p>



                    <div class="payment-methods">

                        <script type="text/javascript">
                            
                            var payment = new Payment('checkout-payment-method-load', 'https://www.nongsanngon.com.vn/checkout/onepage/savePayment/');
                        
</script>


                        <dl id="checkout-payment-method-load">

                            <dt>
                                <span class="no-display">
                                    <input id="p_method_checkmo" value="checkmo" type="radio" name="payment[method]" checked="checked" /></span>
                                <label for="p_method_checkmo">Thanh toán khi nhận hàng</label>
                            </dt>
                        </dl>
                    </div>
                    <script type="text/javascript">
                        

                        $$('.cvv-what-is-this').each(function (element) {
                            Event.observe(element, 'click', toggleToolTip);
                        });

                        function toggleToolTip(event) {
                            if ($('payment-tool-tip')) {
                                $('payment-tool-tip').setStyle({
                                    left: (Event.pointerX(event) - 100) + 'px',
                                    top: (Event.pointerY(event) - 300) + 'px'
                                });
                                $('payment-tool-tip').toggle();
                            }
                            Event.stop(event);
                        }

                        var checkout = new Checkout();
                        $$('#checkout-payment-method-load dt input').invoke('observe', 'click', function (e) {

                            var element = e.element();
                            var name = 'payment_form_' + element.getValue();
                            payment.currentMethod = element.getValue();
                            /* Hide all other forms */
                            $$('dd.payment-method').invoke('hide');

                            if (element.checked) {
                                var form = $(name);
                                var container = $('container_payment_method_' + element.getValue());

                                if (element !== null && container !== null) {
                                    container.show();
                                    $(name).show();
                                }
                            }
                        });


                        payment.currentMethod = "checkmo";
                     
</script>
                    <div class="tool-tip" id="payment-tool-tip" style="display: none;">
                        <div class="btn-close">
                            <a href="#" id="payment-tool-tip-close">
                                <img src="https://www.nongsanngon.com.vn/skin/frontend/shopper/default/images/btn_window_close.gif" alt="Đóng" /></a>
                        </div>
                        <div class="block-content">
                            <img src="https://www.nongsanngon.com.vn/skin/frontend/base/default/images/cvv.gif" alt="Card Verification Number Visual Reference" />
                        </div>
                    </div>

                   @* <div class="onestepcheckout-shipping-method">
                        <p class="onestepcheckout-numbers onestepcheckout-numbers-3">Phương thức vận chuyển</p>


                        <div class="onestepcheckout-shipping-method-block">
                            <script>
                                var sendMethodTime = function (urllink, code) {
                                    var delvT = jQuery('#delvTimeInSecond-' + code).val();
                                    jQuery("#delivery_time").val(delvT);
                                    urllink += '?method=' + delvT;
                                    jQuery.ajax({
                                        url: urllink,
                                        success: function (received) {
                                            var jsonObj = jQuery.parseJSON(received);
                                            jQuery("#delivery_time").val(jsonObj.html);
                                            //jQuery('#display-EstT-'+code).show();
                                        }
                                    });
                                }
                                jQuery(document).ready(function () {
                                    jQuery("input[name='shipping_method']:checked").trigger('click');
                                });
                                var showTooltip = function (text, id) {
                                    jQuery("#" + id).tipTip({ content: text, delay: 0 });
                                };
</script>
                            <dl class="shipment-methods">
                                <dd></dd>
                                <dt style="margin-bottom: 5px;">
                                    <input onclick="sendMethodTime('https://www.nongsanngon.com.vn/delivery/shipping/get_est_time/', 'flatrate4_flatrate4')" name="shipping_method" type="radio" class="validate-one-required-by-name" value="flatrate4_flatrate4" id="s_method_flatrate4_flatrate4" />
                                    <label id="tiptip_flatrate4_flatrate4" onmouseover="showTooltip('Giá: 10,000VND hoặc MIỄN PHÍ với đơn hàng trên 200,000VND', 'tiptip_flatrate4_flatrate4');return;" for="s_method_flatrate4_flatrate4">Sáng: 10AM-12PM (Cho đơn đặt trước 7AM)</label>
                                    <input type="hidden" name="smart_delivery" id="delvTimeInSecond-flatrate4_flatrate4" value="" />
                                </dt>
                                <dd></dd>
                                <dt style="margin-bottom: 5px;">
                                    <input onclick="sendMethodTime('https://www.nongsanngon.com.vn/delivery/shipping/get_est_time/', 'flatrate2_flatrate2')" name="shipping_method" type="radio" class="validate-one-required-by-name" value="flatrate2_flatrate2" id="s_method_flatrate2_flatrate2" />
                                    <label id="tiptip_flatrate2_flatrate2" onmouseover="showTooltip('Giá: 10,000VND hoặc MIỄN PHÍ với đơn hàng trên 200,000VND', 'tiptip_flatrate2_flatrate2');return;" for="s_method_flatrate2_flatrate2">Chiều sớm: 3PM-5PM (Cho đơn đặt trước 11AM)</label>
                                    <input type="hidden" name="smart_delivery" id="delvTimeInSecond-flatrate2_flatrate2" value="" />
                                </dt>
                                <dd></dd>
                                <dt style="margin-bottom: 5px;">
                                    <input onclick="sendMethodTime('https://www.nongsanngon.com.vn/delivery/shipping/get_est_time/', 'flatrate5_flatrate5')" name="shipping_method" type="radio" class="validate-one-required-by-name" value="flatrate5_flatrate5" id="s_method_flatrate5_flatrate5" />
                                    <label id="tiptip_flatrate5_flatrate5" onmouseover="showTooltip('Giá: 10,000VND hoặc MIỄN PHÍ với đơn hàng trên 200,000VND', 'tiptip_flatrate5_flatrate5');return;" for="s_method_flatrate5_flatrate5">Chiều muộn: 5PM-6PM (Cho đơn đặt trước 11AM)</label>
                                    <input type="hidden" name="smart_delivery" id="delvTimeInSecond-flatrate5_flatrate5" value="" />
                                </dt>
                                <dd></dd>
                                <dt style="margin-bottom: 5px;">
                                    <input onclick="sendMethodTime('https://www.nongsanngon.com.vn/delivery/shipping/get_est_time/', 'flatrate3_flatrate3')" name="shipping_method" type="radio" class="validate-one-required-by-name" value="flatrate3_flatrate3" id="s_method_flatrate3_flatrate3" />
                                    <label id="tiptip_flatrate3_flatrate3" onmouseover="showTooltip('Vui lòng xác nhậnthời gian nhận hàng với nhân viên Nông Sản Ngon qua điện thoại trước khi đến. Địa chỉ cửa hàng: Cổng sau 224 Hoàng Ngân, Trung Hòa, Hà Nội. ĐT: 01993 344 344', 'tiptip_flatrate3_flatrate3');return;" for="s_method_flatrate3_flatrate3">Nhận tại cửa hàng (Miễn Phí)</label>
                                    <input type="hidden" name="smart_delivery" id="delvTimeInSecond-flatrate3_flatrate3" value="" />
                                </dt>
                                <input type="hidden" name="delivery_time" id="delivery_time" value="" />
                            </dl>
                        </div>
                    </div>*@


                    <script>
                       
                        jQuery(document).ready(function () {
                            jQuery('#onestepcheckout-coupons-tittle').click(function () {
                                var visibility = jQuery('#onestepcheckout-coupons-wrapper').is(":visible");
                                if (!visibility) {
                                    jQuery('#onestepcheckout-coupons-wrapper').slideDown();
                                } else {
                                    jQuery('#onestepcheckout-coupons-wrapper').slideUp();
                                }
                            });
                        });
                      
		</script>
                   @* <div class="onestepcheckout-coupons">
                        <p style="cursor: pointer;" id="onestepcheckout-coupons-tittle" class="onestepcheckout-numbers onestepcheckout-numbers-4">Phiếu giảm giá<span class="tip-italic"> (nếu có)</span></p>
                        <div id="onestepcheckout-coupons-wrapper">
                            <div id="coupon-notice" style="display: none;"></div>
                            <!--<label for="id_couponcode">Mã giảm giá:</label><br/>-->
                            <input class="input-text" type="text" placeholder="Mã phiếu giảm giá" name="onestepcheckout-couponcode" id="id_couponcode" value="" />
                            <button id="onestepcheckout-coupon-add" class="form-button-alt" type="button">Sử dụng</button>
                            <button id="onestepcheckout-coupon-remove" class="form-button-alt" type="button" style="display: none;">Hủy phiếu</button>
                            <script>
                                document.observe('dom:loaded', function () {
                                    $('onestepcheckout-coupon-add').observe('click', function (e) {
                                        var coupon = $('id_couponcode').getValue();
                                        var couponNotice = $('coupon-notice');
                                        couponNotice.hide();
                                        if (coupon == '') {
                                            alert('Xin vui lòng nhập phiếu mua hàng hợp lệ.');
                                            return;
                                        }

                                        var url = 'https://www.nongsanngon.com.vn/onestepcheckout/ajax/add_coupon/';
                                        var parameters = { code: coupon };
                                        var summary = $$('div.onestepcheckout-summary').first();

                                        summary.update('<div class="loading-ajax">&nbsp;</div>');

                                        new Ajax.Request(url, {
                                            method: 'post',
                                            parameters: parameters,
                                            onSuccess: function (transport) {
                                                if (transport.status == 200) {

                                                    var response = transport.responseText.evalJSON();

                                                    if (response.success) {
                                                        summary.update(response.summary);
                                                        var message = "Phiếu giảm giá hợp lệ!";
                                                        couponNotice.update(message);
                                                        couponNotice.removeClassName('error-msg');
                                                        couponNotice.addClassName('success-msg');
                                                        couponNotice.show();
                                                        /* Show remove button */
                                                        $('onestepcheckout-coupon-remove').show();
                                                    }
                                                    else {
                                                        summary.update(response.summary);
                                                        var message = "Mã số phiếu không hợp lệ!";
                                                        couponNotice.update(message);
                                                        couponNotice.removeClassName('success-msg');
                                                        couponNotice.addClassName('error-msg');
                                                        couponNotice.show();
                                                        /* Hide remove button */
                                                        $('onestepcheckout-coupon-remove').hide();
                                                    }
                                                }
                                            }
                                        });
                                    });

                                    $('onestepcheckout-coupon-remove').observe('click', function (e) {
                                        var coupon = $('id_couponcode').getValue();
                                        var couponNotice = $('coupon-notice');
                                        couponNotice.hide();
                                        var url = 'https://www.nongsanngon.com.vn/onestepcheckout/ajax/add_coupon/';
                                        var parameters = { code: coupon, remove: '1' };
                                        var summary = $$('div.onestepcheckout-summary').first();

                                        summary.update('<div class="loading-ajax">&nbsp;</div>');

                                        new Ajax.Request(url, {
                                            method: 'post',
                                            parameters: parameters,
                                            onSuccess: function (transport) {
                                                if (transport.status == 200) {
                                                    var response = transport.responseText.evalJSON();

                                                    if (response.success) {
                                                        $('id_couponcode').setValue('')
                                                        $('onestepcheckout-coupon-remove').hide();
                                                    }
                                                    var summary = $$('div.onestepcheckout-summary').first();

                                                    summary.hide();
                                                    summary.update(response.summary);
                                                    summary.show();

                                                    couponNotice.hide();
                                                    couponNotice.update(response.message);
                                                    couponNotice.removeClassName('error-msg');
                                                    couponNotice.addClassName('success-msg');
                                                    couponNotice.show();
                                                }
                                            }
                                        });
                                    });
                                });
                </script>
                        </div>
                    </div>*@
                    <div class="onestepcheckout-comments">
                        <p class="onestepcheckout-numbers onestepcheckout-numbers-5">Gửi lời nhắn</p>
                        @Html.TextAreaFor(m => m.Ghi_chu, new {id="id_comments",placeholder = "Nhắn các thông tin hoặc yêu cầu vận chuyển đặc biệt", name ="onestepcheckout_comments" })                       
                    </div>
                </div>

                <div class="onestepcheckout-column-right">
                    <p class="onestepcheckout-numbers">Thông tin giỏ hàng&nbsp;<span class="onestepcheckout-edit-cart"><a href="@Url.Action("Xemgiohang","Home")">(Thay đổi)</a></span></p>
                    <div class="onestepcheckout-summary">

                        <table class="onestepcheckout-summary" id="onestepcheckout-summary-table">
                            <thead>
                                <tr>
                                    <th class="name">Sản phẩm</th>
                                    <th class="qty">Số lượng</th>
                                    <th class="total">Thành tiền</th>
                                </tr>
                            </thead>

                            @for(int i=0;i<lstdn.Count;i++){
                            <tr>
                                <td class="name">@lstdn[i].Ten </td>
                                <td class="qty">@sl[i]</td>
                                <td class="total">
                                    <span class="price">@(lstdn[i].Gia*sl[i]) đ</span>
                                    <div style="display:none">@(tongthanhtoan+=lstdn[i].Gia*sl[i])</div>
                                </td>
                            </tr>
                            }
                        </table>

                        <script type="text/javascript">decorateTable('onestepcheckout-summary-table')</script>
                  
                        @Html.Hidden("Tong_tien", tongthanhtoan)
                        @Html.Hidden("Phi_ship", 10000)
                        @Html.Hidden("Trang_thai", false)
                        @Html.Hidden("ID_Nguoidung", 1)
                        @Html.Hidden("Ngay_thang", DateTime.Now)

                        <table class="onestepcheckout-totals">
                            <tr>
                                <td class="title">Thành tiền		</td>
                                <td class="value">
                                    <span class="price">@tongthanhtoan đ</span>		</td>
                            </tr>
                            <tr>
                                <td class="title">Phí vận chuyển		</td>
                                <td class="value">
                                    <span class="price">10.000 đ</span>		</td>
                            </tr>
                            <tr class="grand-total">
                                <td class="title">Tổng hóa đơn		</td>
                                <td class="value">
                                    <span class="price">@(tongthanhtoan+10000) đ</span>		</td>
                            </tr>
                        </table>
                    </div>






                    <br />
                    <div class="onestepcheckout-enable-terms">

                        <input class="required-entry" type="checkbox" id="id_accept_terms" name="accept_terms" value="1" checked="checked" />
                        <label for="id_accept_terms">Tôi xác nhận thông tin đơn hàng & đồng ý với các <strong><a href="/dieu-kien-va-dieu-khoan/" target="_blank">chính sách chung</a></strong></label>


                    </div>

                    <div class="onestepcheckout-place-order">
                       
                        <button type="submit" title="Gửi đơn hàng" class="large orange onestepcheckout-button">
                            <span><span>Gửi đơn hàng</span></span></button>
                    </div>


                </div>

                <div style="clear: both;">&nbsp;</div>

            </div>

        </fieldset>
    }
    















   @* <div id="onestepcheckout-login-popup" style="display: none;">
        <div class="onestepcheckout-popup-wrapper">
            <div class="onestepcheckout-popup-contents">

                <div id="onestepcheckout-login-popup-contents-forgot" style="display: none;">
                    <h1>Quên mật khẩu</h1>
                    <p>Nhập email của bạn vào đây, chúng tôi sẽ gửi mật khẩu mới cho bạn</p>

                    <form id="onestepcheckout-forgot-form">

                        <div id="onestepcheckout-forgot-loading" style="display: none;" class="loading-ajax">&nbsp;</div>
                        <div id="onestepcheckout-forgot-error" class="onestepcheckout-error" style="display: none;">&nbsp;</div>
                        <div id="onestepcheckout-forgot-success" style="display: none;">
                            We have now sent you a new password to your email address. Click the link below to return to login.               
                        </div>

                        <table id="onestepcheckout-forgot-table">
                            <tr>
                                <td style="width: 25%;">
                                    <label for="id_onestepcheckout_email">Địa chỉ email</label></td>
                                <td style="width: 40%;">
                                    <input type="text" class="input-text" name="onestepcheckout_email" id="id_onestepcheckout_email" /></td>
                                <td style="width: 45%; text-align: center;">
                                    <button id="onestepcheckout-forgot-button" type="button">Gửi mật khẩu</button></td>
                            </tr>
                        </table>
                    </form>

                    <p style="margin-top: 10px;"><a href="#" id="onestepcheckout-return-login-link">Quay lại đăng nhập</a></p>

                </div>

                <div id="onestepcheckout-login-popup-contents-login">

                    <h1>Đăng nhập</h1>

                    <p>Vui lòng đăng nhập với email và mật khẩu của bạn</p>
                    <form id="onestepcheckout-login-form">

                        <div id="onestepcheckout-login-loading" style="display: none;" class="loading-ajax">&nbsp;</div>
                        <div id="onestepcheckout-login-error" class="onestepcheckout-error" style="display: none;">&nbsp;</div>


                        <table id="onestepcheckout-login-table">
                            <tr>
                                <td style="width: 30%;">
                                    <label for="id_onestepcheckout_username">Địa chỉ email</label></td>
                                <td style="width: 51%;">
                                    <input tabindex="100" type="text" class="input-text" name="onestepcheckout_username" id="id_onestepcheckout_username" /></td>
                                <td rowspan="2" style="width: 19%; vertical-align: middle;">
                                    <button tabindex="102" id="onestepcheckout-login-button" type="button">Đăng nhập</button></td>
                            </tr>
                            <tr>
                                <td>
                                    <label for="id_onestepcheckout_password">Mật khẩu</label></td>
                                <td>
                                    <input type="password" tabindex="101" name="onestepcheckout_password" class="input-text" id="id_onestepcheckout_password" /></td>
                            </tr>

                        </table>
                    </form>

                    <p style="margin-top: 10px;"><a href="#" id="onestepcheckout-forgot-password-link">Quên mật khẩu</a></p>



                </div>

                <p class="close"><a href="#">Đóng</a></p>
            </div>

        </div>
        <div class="onestepcheckout-popup-footer">&nbsp;</div>

    </div>*@
    <script>
        var login_popup;
        Event.observe(window, 'load', function () {

            var button = $('onestepcheckout-login-button');
            var loginButtonFunction = function (e) {

                /* Hide form and display loading */
                var table = $('onestepcheckout-login-table');
                var loading = $('onestepcheckout-login-loading');
                var error = $('onestepcheckout-login-error');

                table.hide();
                error.hide();
                loading.show();


                var form = $('onestepcheckout-login-form');
                var url = 'https://www.nongsanngon.com.vn/onestepcheckout/ajax/login/';
                new Ajax.Request(url, {
                    parameters: form.serialize(true),
                    method: 'POST',
                    onComplete: function (transport) {
                        if (transport.status == 200) {
                            var result = transport.responseText.evalJSON();

                            if (!result.success) {
                                loading.hide();

                                error.update(result.error);
                                error.show();

                                table.show();
                            }
                            else {
                                // Successfully logged in user, now reload page
                                //window.location.reload(true);
                                window.location = window.location;
                            }
                        }
                    }
                })
            };

            var onkeypressHandler = function (event) {
                if (event.keyCode == Event.KEY_RETURN) {
                    event.preventDefault();
                    loginButtonFunction();
                }
            };

            login_popup = new OneStepCheckout_Popup('onestepcheckout-login-popup', 'onestepcheckout-login-link', 'div#onestepcheckout-login-popup p.close a', function () {
                /* Callback for closing the popup */
                Event.stopObserving(document, 'keypress', onkeypressHandler);
            }, function () {
                /* Callback for opening the popup */
                Event.observe(document, 'keypress', onkeypressHandler);

                /* Reset error messages and state */
                $('onestepcheckout-login-error').hide();
                $('onestepcheckout-forgot-error').hide();
                $('onestepcheckout-login-popup-contents-forgot').hide();
                $('onestepcheckout-login-popup-contents-login').show();


            });

            button.observe('click', loginButtonFunction);

            $('onestepcheckout-forgot-password-link').observe('click', function (e) {
                Event.stop(e);
                $('onestepcheckout-login-error').hide();
                $('onestepcheckout-login-popup-contents-login').hide();
                $('onestepcheckout-login-popup-contents-forgot').show();

            });

            $('onestepcheckout-return-login-link').observe('click', function (e) {
                Event.stop(e);
                $('onestepcheckout-forgot-error').hide();
                $('onestepcheckout-login-popup-contents-forgot').hide();
                $('onestepcheckout-login-popup-contents-login').show();

            });

            var forgot_password_button = $('onestepcheckout-forgot-button');

            forgot_password_button.observe('click', function (e) {

                var table = $('onestepcheckout-forgot-table');
                var loading = $('onestepcheckout-forgot-loading');
                var error = $('onestepcheckout-forgot-error');
                var success = $('onestepcheckout-forgot-success');
                var email = $('id_onestepcheckout_email').getValue();

                if (email != '') {

                    table.hide();
                    error.hide();
                    loading.show();

                    var url = 'https://www.nongsanngon.com.vn/onestepcheckout/ajax/forgotPassword/';
                    var parameters = { email: email };

                    new Ajax.Request(url, {
                        method: 'post',
                        parameters: parameters,
                        onSuccess: function (transport) {
                            var result = transport.responseText.evalJSON();

                            if (result.success) {
                                loading.hide();
                                success.show();
                            }
                            else {
                                error.update('Vui lòng nhập địa chỉ email đã đăng ký');
                                error.show();
                                table.show();
                                loading.hide();
                            }
                        }
                    });

                }
                else {
                    alert('Vui lòng nhập email hợp lệ');
                }
            });


        });
</script>






    <div id="onestepcheckout-toc-popup" style="display: none;">

        <div class="onestepcheckout-popup-wrapper">
            <div class="onestepcheckout-popup-wrapper-inner">
                <h1></h1>

                <div class="onestepcheckout-toc-terms">
                </div>

                <p class="close"><a href="#">Đóng</a></p>
            </div>
        </div>
        <div class="onestepcheckout-popup-footer">&nbsp;</div>
    </div>
    <script>
        var popup;
        Event.observe(window, 'load', function () {
            popup = new OneStepCheckout_Popup('onestepcheckout-toc-popup', 'onestepcheckout-toc-link', 'div#onestepcheckout-toc-popup p.close a');
        });
</script>





    <script>
</script>


    <script type="text/javascript">

        document.observe('dom:loaded', function () {
            if ($$('div.shopping-cart-totals').length == 1) {
            }
            else {

                var already_placing_order = false;

                /* Fix issue with bad centering due to parent */
                $(document.body).insert($('onestepcheckout-login-popup'));
                $(document.body).insert($('onestepcheckout_popup_overlay'));
                $(document.body).insert($('onestepcheckout-toc-popup'));

                /* Handle place order click event */
                $('onestepcheckout-place-order').observe('click', function (e) {
                    Event.stop(e);

                    // First validate the form
                    var form = new VarienForm('onestepcheckout-form');

                    if (!form.validator.validate()) {
                        Event.stop(e);
                        $('onestepcheckout-error-inform').show();
                    }
                    else {

                        if (!already_placing_order) {

                            already_placing_order = true;

                            var element = new Element('div').
                                addClassName('onestepcheckout-place-order-loading').
                                update('<img src="https://www.nongsanngon.com.vn/skin/frontend/shopper/default/images/ajax-loader.gif" width="24" height="24" />&nbsp;&nbsp;Đang gửi đơn hàng...');



                            this.parentNode.appendChild(element);
                            element.hide();

                            /* Disable button to avoid multiple clicks */

                            jQuery.fancybox({
                                padding: 0,
                                content: '<img src="https://www.nongsanngon.com.vn/skin/frontend/shopper/default/images/ajax-loader.gif" width="24" height="24" />&nbsp;&nbsp;<span style="color: #000;"><strong>Đang gửi đơn hàng...</strong></span>',
                                wrapCSS: 'fancybox-custom',
                                closeClick: false,
                                hideOnOverlayClick: false,
                                overlayOpacity: 0.6,
                                showCloseButton: false,
                                enableEscapeButton: false,
                                helpers: {
                                    title: {
                                        type: 'inside'
                                    },
                                    overlay: {
                                        css: {
                                            'background-color': '#777'
                                        }
                                    }
                                }
                            });

                            e.element().removeClassName('orange').addClassName('grey');
                            var element = e.element();
                            element.disabled = true;

                            $('onestepcheckout-error-inform').hide();

                            /* Submit the form */
                            $('onestepcheckout-form').submit();
                        }
                    }
                });


                // This is a separate page
                var url = 'https://www.nongsanngon.com.vn/onestepcheckout/ajax/set_methods_separate/';
                var update_payments = false;

                $$('dl.shipment-methods input').invoke('observe', 'click', get_separate_save_methods_function(url, update_payments));
                $$('div.payment-methods input[name^=payment\[method\]]').invoke('observe', 'click', get_separate_save_methods_function(url));

                $$('div.payment-methods input[name^=payment\[method\]]').invoke('observe', 'click', function () {
                    $$('div.onestepcheckout-payment-method-error').each(function (item) {
                        new Effect.Fade(item);
                    });
                });

                $$('dl.shipment-methods input').invoke('observe', 'click', function () {
                    $$('div.onestepcheckout-shipment-method-error').each(function (item) {
                        new Effect.Fade(item);
                    });
                });

                var has_hidden_terms = false;

                if ($('id_accept_terms') != null) {

                    $('id_accept_terms').observe('click', function (e) {
                        var element = e.element();

                        if (element.checked) {
                            $$('div.onestepcheckout-terms-error').each(function (item) {
                                new Effect.Fade(item);
                                has_hidden_terms = true;
                            });
                        }
                        else {
                            if (has_hidden_terms) {
                                $$('div.onestepcheckout-terms-error').each(function (item) {
                                    new Effect.Appear(item);
                                    has_hidden_terms = false;
                                });
                            }
                        }
                    });
                }
            }

            var form = $('onestepcheckout-form');

            /* Highlight selected payment method if one set */
            if ($RF(form, 'payment[method]') != null) {
                try {
                    var payment_method = $RF(form, 'payment[method]');
                    jQuery('container_payment_method_' + payment_method).show();
                    jQuery('payment_form_' + payment_method).show();
                } catch (err) {

                }
            }

            /* Set default shipping method if not set */
            if ($RF(form, 'shipping_method') == null) {
                try {
                    var method = 'flatrate4_flatrate4';
                    if (method != '') {
                        jQuery('s_method_' + method).checked = true;
                        get_separate_save_methods_function(url)();
                    }
                } catch (err) {

                }
            }

            get_separate_save_methods_function(url)();

            $('billing:use_for_shipping_yes').observe('click', function (e) {
                var element = e.element();
                if (!element.checked) {
                    $('shipping_address').hide();
                } else {
                    $('shipping_address_list').show();
                    $('shipping_address').show();
                }

                get_save_billing_function('https://www.nongsanngon.com.vn/onestepcheckout/ajax/save_billing/', 'https://www.nongsanngon.com.vn/onestepcheckout/ajax/set_methods_separate/', false)();

            });


            var url_save_billing = 'https://www.nongsanngon.com.vn/onestepcheckout/ajax/save_billing/';
            var url_set_methods = 'https://www.nongsanngon.com.vn/onestepcheckout/ajax/set_methods_separate/';
            var update_payments = false;
            var update_on_initial = false;

            var shipping_address_select = $('shipping-address-select');
            var billing_address_select = $('billing-address-select');



            $('billing:region_id').observe('change', get_save_billing_function(url_save_billing, url_set_methods, update_payments));
            $('billing:region').observe('change', get_save_billing_function(url_save_billing, url_set_methods, update_payments));

            $('shipping:region_id').observe('change', get_save_billing_function(url_save_billing, url_set_methods, update_payments));
            $('shipping:region').observe('change', get_save_billing_function(url_save_billing, url_set_methods, update_payments));







        });

        if ($('payment-tool-tip-close')) {
            Event.observe($('payment-tool-tip-close'), 'click', toggleToolTip);
        }

</script>

    <!-- Facebook Conversion Code for Checkout -->
    <script type="text/javascript">
        var fb_param = {};
        fb_param.pixel_id = '6012194836448';
        fb_param.value = '0.01';
        fb_param.currency = 'USD';
        (function () {
            var fpw = document.createElement('script');
            fpw.async = true;
            fpw.src = '//connect.facebook.net/en_US/fp.js';
            var ref = document.getElementsByTagName('script')[0];
            ref.parentNode.insertBefore(fpw, ref);
        })();
</script>
    <noscript>
        <img height="1" width="1" alt="" style="display: none" src="https://www.facebook.com/offsite_event.php?id=6012194836448&amp;value=0.01&amp;currency=USD" />
    </noscript>

    <!-- Google Code for Purchase Conversion Page -->
    <script type="text/javascript">
        /* <![CDATA[ */
        var google_conversion_id = 977740319;
        var google_conversion_language = "en";
        var google_conversion_format = "2";
        var google_conversion_color = "ffffff";
        var google_conversion_label = "5haxCJHMpgcQn8Sc0gM";
        var google_conversion_value = 0;
        var google_remarketing_only = false;
        /* ]]> */
</script>
    <script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
    <noscript>
        <div style="display: inline;">
            <img height="1" width="1" style="border-style: none;" alt="" src="//www.googleadservices.com/pagead/conversion/977740319/?value=0&amp;label=5haxCJHMpgcQn8Sc0gM&amp;guid=ON&amp;script=0" />
        </div>
    </noscript>
    <div id="onestepcheckout_popup_overlay" style="display: none;">&nbsp;</div>
</div>
}